//导入http模块
const http = require('http')

// 创建服务对象
const server = http.createServer((request, response) => {
    // request.url
    console.log(request.url);
    let url = new URL(request.url, 'http://localhost:9000')
    console.log("🚀🚀🚀 ~ file: 06_提取http报文中的URL和查询字符串.js:9 ~ server ~ url:", url)

    console.log(url.pathname);
    console.log(url.searchParams.get('name'));
    console.log(url.searchParams.get('password'));
    response.setHeader('Content-Type', 'text/html;charset=utf-8')
    // 设置响应体
    response.end('url2')
})

// 监听端口，启动服务
server.listen(9000, () => {
    console.log('服务启动成功...')
})